<template>
    <div class="resources index">
        <Header></Header>
        <div class="main">
            <p class="current-nav">
                当前位置 :
                <router-link to="index">首页</router-link>
                <i>></i>
                <a>风险评估及资源调查</a>
                <i>></i>应急资源信息
            </p>

            <div class="infor resource">
                <!-- <p class="title">应急资源信息</p> -->
                <ul class="clearfix steps" style="margin-top:30px;">
                    <li class="steps-active" @click="goToPage(0)">
                        <span>1</span>
                        <p>风险信息</p>
                        <p class="info_note clearfix">
                            <i class="el-icon-warning-outline"></i>
                            <span
                                >请录入单位涉及的全部风险信息再进入下一步，否则可能导致推荐的应急预案不完整！</span
                            >
                        </p>
                    </li>
                    <li class="steps-active" @click="goToPage(1)">
                        <span>2</span>
                        <p style="margin-left:-13px;">应急资源信息</p>
                        <p class="info_note clearfix">
                            <i class="el-icon-warning-outline"></i>
                            <span
                                >请正确填写应急资源信息，该信息会自动更新到应急预案中！</span
                            >
                        </p>
                    </li>
                    <!-- <li>
                        <span>3</span>
                        <p>报告信息</p>
                        <p class="info_note clearfix">
                            <i class="el-icon-warning-outline"></i>
                            <span>请正确填写单位基本信息，该信息会自动更新到对应的应急预案中！</span>
                        </p>
                    </li> -->
                </ul>
                <div class="form-container">
                    <div class="bts-group">
                        <div class="items">
                            <el-button
                                class="sure"
                                @click="dialogVisible = true"
                            >
                                <i class="el-icon-download">模板下载</i>
                            </el-button>
                        </div>
                        <div class="items">
                            <el-upload
                                action="/emergency/v1.0/upload/file"
                                ref="reportUpload"
                                :on-change="changeimg3"
                                :http-request="newload"
                                :show-file-list="false"
                                accept=".xls, .xlsx"
                            >
                                <el-button class="grp1">
                                    <i class="el-icon-upload2"
                                        >上传内部应急组织机构</i
                                    >
                                </el-button>
                            </el-upload>
                        </div>
                        <div class="items">
                            <el-upload
                                action="/emergency/v1.0/upload/file"
                                ref="reportUpload"
                                :on-change="changeimg3"
                                :http-request="newload1"
                                :show-file-list="false"
                                accept=".xls, .xlsx"
                            >
                                <el-button class="grp1">
                                    <i class="el-icon-upload2"
                                        >上传外部应急救援队伍</i
                                    >
                                </el-button>
                            </el-upload>
                        </div>
                        <div class="items">
                            <el-upload
                                action="/emergency/v1.0/upload/file"
                                ref="reportUpload"
                                :on-change="changeimg3"
                                :http-request="newload2"
                                :show-file-list="false"
                                accept=".xls, .xlsx"
                            >
                                <el-button class="grp1">
                                    <i class="el-icon-upload2"
                                        >上传应急物资装备</i
                                    >
                                </el-button>
                            </el-upload>
                        </div>
                        <div class="items">
                            <el-upload
                                action="/emergency/v1.0/upload/file"
                                ref="reportUpload"
                                :on-change="changeimg3"
                                :http-request="newload3"
                                :show-file-list="false"
                                accept=".png, .jpg, .jpeg"
                            >
                                <el-button class="grp1">
                                    <i class="el-icon-upload2"
                                        >上传应急救援协议</i
                                    >
                                </el-button>
                            </el-upload>
                        </div>
                    </div>
                    <el-table
                        ref="multipleTable"
                        :data="contentList"
                        tooltip-effect="dark"
                        v-loading.fullscreen.lock="loading"
                        :element-loading-text="wordmsg"
                        element-loading-spinner="el-icon-loading"
                        element-loading-background="rgba(0, 0, 0, 0.8)"
                        @selection-change="handleSelectionChange"
                    >
                        <el-table-column
                            type="index"
                            align="center"
                            label="序号"
                        ></el-table-column>
                        <!--	<el-table-column label='' type="selection"  align='center'>
                        </el-table-column>-->
                        <el-table-column
                            prop="originalFileName"
                            label="文件名称"
                            :show-overflow-tooltip="true"
                            align="center"
                        ></el-table-column>
                        <el-table-column
                            prop="fileSize"
                            label="大小"
                            :show-overflow-tooltip="true"
                            align="center"
                        >
                            <template slot-scope="scope">
                                <span>{{
                                    scope.row.fileSize | sizechange
                                }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="createUser"
                            label="上传人"
                            :show-overflow-tooltip="true"
                            align="center"
                        ></el-table-column>
                        <el-table-column
                            prop="createTime"
                            label="上传时间"
                            :show-overflow-tooltip="true"
                            align="center"
                        >
                            <template slot-scope="scope">
                                <span>{{
                                    scope.row.createTime.split(" ")[0]
                                        | timechange
                                }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            label="操作"
                            width="300px"
                            align="center"
                        >
                            <template slot-scope="scope">
                                <el-button
                                    class="detail-btn"
                                    @click="lookdetail(scope.row)"
                                >
                                    <i class="el-icon-search">查看</i>
                                </el-button>
                                <el-button
                                    class="detail-btn"
                                    @click="deletedetail(scope.row)"
                                >
                                    <i class="el-icon-delete">删除</i>
                                </el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div class="bts">
                        <el-button @click="resetForm('ruleForm')" class="cancel"
                            >上一步</el-button
                        >
                        <el-button
                            type="primary"
                            @click="judgeRequired"
                            class="sure surexx"
                            >保存</el-button
                        >
                    </div>
                </div>
            </div>
        </div>
        <el-dialog title="模板下载" :visible.sync="dialogVisible" width="45%">
            <p class="resource-title">选择你要下载的模板类型</p>
            <div class="resource-bts">
                <a
                    download
                    @click="activeIndex = 0"
                    :class="activeIndex == 0 ? 'btn-active' : ''"
                    v-bind:href="businessId | innerOrg"
                    >内部应急组织机构</a
                >
                <a
                    download
                    @click="activeIndex = 1"
                    :class="activeIndex == 1 ? 'btn-active' : ''"
                    href="../../../static/外部应急救援队伍联系方式.xlsx"
                    >外部应急救援队伍</a
                >
                <a
                    @click="activeIndex = 2"
                    :class="activeIndex == 2 ? 'btn-active' : ''"
                    download
                    href="../../../static/应急物资装备清单.xlsx"
                    >应急物资装备</a
                >
            </div>
        </el-dialog>

        <!--查看详情-->
        <el-dialog
            title="内部应急组织机构清单"
            :visible.sync="firstVisible"
            width="900"
        >
            <el-table
                ref="multipleTable"
                :data="firstVisibleList"
                tooltip-effect="dark"
                style="width:100%;"
            >
                <el-table-column
                    type="index"
                    align="center"
                    label="序号"
                ></el-table-column>
                <el-table-column
                    prop="userName"
                    show-overflow-tooltip
                    label="姓名"
                    align="center"
                ></el-table-column>
                <el-table-column
                    prop="type"
                    label="类型"
                    show-overflow-tooltip
                    align="center"
                >
                    <template slot-scope="scope">
                        <span>
                            {{ scope.row.type | changeType }}
                        </span>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="phoneNo"
                    label="电话"
                    show-overflow-tooltip
                    align="center"
                ></el-table-column>
                <el-table-column
                    prop="station"
                    label="岗位"
                    show-overflow-tooltip
                    align="center"
                >
                    <template slot-scope="scope">
                        <span>
                            {{ scope.row.station | changestatus }}
                        </span>
                    </template>
                </el-table-column>
            </el-table>

            <div>
                <el-pagination
                    @current-change="looknew1"
                    :current-page.sync="pageIndex"
                    :page-size="pageSize"
                    layout="total, prev, pager, next, jumper"
                    :total="total"
                ></el-pagination>
            </div>
        </el-dialog>

        <!--查看详情-->
        <el-dialog
            title="应急物资装备清单"
            :visible.sync="threeVisible"
            width="900"
        >
            <el-table
                ref="multipleTable"
                :data="threeVisibleList"
                tooltip-effect="dark"
                style="width:100%;"
            >
                <el-table-column
                    type="index"
                    align="center"
                    label="序号"
                ></el-table-column>
                <el-table-column
                    prop="equipmentName"
                    show-overflow-tooltip
                    label="物质名称"
                    align="center"
                >
                    <template slot-scope="scope">
                        <span>{{ scope.row.equipmentName }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="modelNum"
                    label="规格"
                    show-overflow-tooltip
                    align="center"
                ></el-table-column>
                <el-table-column
                    prop="quantity"
                    label="数量"
                    show-overflow-tooltip
                    align="center"
                ></el-table-column>
                <el-table-column
                    prop="companyName"
                    label="单位"
                    show-overflow-tooltip
                    align="center"
                ></el-table-column>
                <el-table-column
                    prop="storageArea"
                    label="储存地点"
                    show-overflow-tooltip
                    align="center"
                ></el-table-column>
            </el-table>

            <div>
                <el-pagination
                    @current-change="looknew3"
                    :current-page.sync="pageIndex2"
                    :page-size="pageSize2"
                    layout="total, prev, pager, next, jumper"
                    :total="total1"
                ></el-pagination>
            </div>
        </el-dialog>

        <el-dialog
            title="外部应急救援队伍联系方式"
            :visible.sync="twoVisible"
            width="900px"
        >
            <el-table
                ref="multipleTable"
                :data="twoVisibleList"
                tooltip-effect="dark"
                style="width:100%;"
            >
                <el-table-column
                    type="index"
                    align="center"
                    label="序号"
                ></el-table-column>
                <el-table-column
                    prop="type"
                    :show-overflow-tooltip="true"
                    label="外部应急救援队伍"
                    align="center"
                >
                    <template slot-scope="scope">
                        <span>{{ scope.row.type }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="contactsPerson"
                    label="联系人"
                    :show-overflow-tooltip="true"
                    align="center"
                ></el-table-column>
                <el-table-column
                    prop="phoneNo"
                    label="电话"
                    :show-overflow-tooltip="true"
                    align="center"
                ></el-table-column>
            </el-table>

            <div>
                <el-pagination
                    @current-change="looknew2"
                    :current-page.sync="pageIndex1"
                    :page-size="pageSize1"
                    layout="total, prev, pager, next, jumper"
                    :total="total2"
                ></el-pagination>
            </div>
        </el-dialog>

        <el-dialog
            title="应急救援协议"
            :visible.sync="fourVisible"
            width="900px"
        >
            <iframe width="100%" :src="mgsUrl" height="500">
                <!--http://www.xdocin.com/xdoc?_func=to&amp;_format=html&amp;_cache=1&amp;_xdoc=http://www.xdocin.com/demo/demo.docx
                https://view.officeapps.live.com/op/view.aspx?src=http://storage.xuetangx.com/public_assets/xuetangx/PDF/1.xls-->
            </iframe>
        </el-dialog>
        <Footer />
    </div>
</template>

<script>
import Header from "../common/header";
import Footer from "../common/footer";
export default {
    components: {
        Header,
        Footer
    },
    data () {
        return {
            dialogVisible: false,
            uploadType: [
                "上传内部应急组织机构",
                "上传外部应急救援队伍",
                "上传应急物资装备",
                "上传应急救援协议"
            ],
            modeType: ["内部应急组织机构", "外部应急救援队伍", "应急物资装备"],
            activeIndex2: -1,
            activeIndex: -1,
            formInline: {
                user: "",
                region: ""
            },
            multipleSelection: [],
            currentPage: 1,

            oneList: [],
            twoList: [],
            threesList: [],
            fourList: [],

            companyId: "",

            contentList: [],

            firstVisible: false,
            firstVisibleList: [],

            twoVisible: false,
            twoVisibleList: [],

            threeVisible: false,
            threeVisibleList: [],

            pageIndex: 1,
            pageSize: 5,
            total: 0,

            pageIndex1: 1,
            pageSize1: 5,
            total1: 0,

            pageIndex2: 1,
            pageSize2: 5,
            total2: 0,

            fourVisible: false,
            mgsUrl: "",
            loading: false,
            wordmsg: "",
            businessId: localStorage.businessId,
            navChildren: []
        };
    },
    created () {
        this.navChildren = JSON.parse(this.$route.query.navChildren)
        this.companyId = JSON.parse(localStorage.getItem("user")).companyId;
        this.lookdetailrecord();
    },
    methods: {
        goToPage (index) {
            this.$router.push({
                path: this.navChildren[index].menuUrl,
                query: {
                    navIndex: this.$route.query.navIndex,
                    navChildren: this.$route.query.navChildren
                }
            })
        },
        handleSizeChange (val) {
            console.log(`每页 ${val} 条`);
        },
        handleCurrentChange (val) {
            console.log(`当前页: ${val}`);
        },
        onSubmit () {
            console.log("submit!");
        },
        toggleSelection (rows) {
            if (rows) {
                rows.forEach(row => {
                    this.$refs.multipleTable.toggleRowSelection(row);
                });
            } else {
                this.$refs.multipleTable.clearSelection();
            }
        },
        handleSelectionChange (val) {
            this.multipleSelection = val;
        },
        resetForm (formName) {
            //				this.$refs[formName].resetFields();
            this.$router.push({
                path: "risk",
                query: {
                    navIndex: this.$route.query.navIndex,
                    navChildren: this.$route.query.navChildren
                }
            });
        },
        newload (file) {
            //导入内部应急机组机构

            let url =
                this.$baseUrl +
                "emergencyresources/v1.0/importinnerexecl?companyId=" +
                this.companyId;
            var fd = new FormData();
            fd.append("file", file.file);
            fd.append(
                "userName",
                JSON.parse(localStorage.getItem("user")).userAccount
            );
            // fd.append('单位id', this.companyId)
            let config = {
                headers: {
                    "Content-Type": "multipart/form-data"
                }
            };
            this.wordmsg = "上传中";
            this.loading = true;
            this.$axios.post(url, fd, config).then(res => {
                this.loading = false;
                if (res.data.meta.success) {
                    this.lookdetailrecord();
                    this.$message({
                        message: "上传成功",
                        type: "success"
                    });
                } else {
                    if (res.data.meta.message) {
                        this.$message({
                            message:
                                "上传的excel表格数据为空或excel表格数据格式错误",
                            type: "error"
                        });
                    } else {
                        this.$message({
                            message: "请下载相应的模板填写内容后，再上传文件",
                            type: "error"
                        });
                    }
                }
            });
        },
        newload1 (file) {
            //导入外部应急救援队伍联系方式
            let url =
                this.$baseUrl +
                "emergency/importData?companyId=" +
                this.companyId;
            var fd = new FormData();
            fd.append("file", file.file);
            fd.append(
                "userName",
                JSON.parse(localStorage.getItem("user")).userAccount
            );
            let config = {
                headers: {
                    "Content-Type": "multipart/form-data"
                }
            };
            this.wordmsg = "上传中";
            this.loading = true;
            this.$axios.post(url, fd, config).then(res => {
                console.log(res);
                this.loading = false;
                if (res.data.meta.success) {
                    this.$message({
                        message: "上传成功",
                        type: "success"
                    });
                    this.lookdetailrecord();
                } else {
                    if (res.data.meta.message) {
                        this.$message({
                            message:
                                "上传的excel表格数据为空或excel表格数据格式错误",
                            type: "error"
                        });
                    } else {
                        this.$message({
                            message: "请下载相应的模板填写内容后，再上传文件",
                            type: "error"
                        });
                    }
                }
            });
        },
        newload2 (file) {
            //导入装备清单
            let url =
                this.$baseUrl +
                "emergencyresources/v1.0/importExecl?companyId=" +
                this.companyId;
            var fd = new FormData();
            fd.append("file", file.file);
            fd.append(
                "userName",
                JSON.parse(localStorage.getItem("user")).userAccount
            );
            let config = {
                headers: {
                    "Content-Type": "multipart/form-data"
                }
            };
            this.wordmsg = "上传中";
            this.loading = true;
            this.$axios.post(url, fd, config).then(res => {
                this.loading = false;
                console.log(res);
                if (res.data.meta.success) {
                    this.$message({
                        message: "上传成功",
                        type: "success"
                    });
                    this.lookdetailrecord();
                } else {
                    if (res.data.meta.message) {
                        this.$message({
                            message:
                                "上传的excel表格数据为空或excel表格数据格式错误",
                            type: "error"
                        });
                    } else {
                        this.$message({
                            message: "请下载相应的模板填写内容后，再上传文件",
                            type: "error"
                        });
                    }
                }
            });
        },
        newload3 (file) {
            //导入救援协议
            let flag = false;
            this.contentList.forEach(item => {
                if (item.uploadType == 4) {
                    flag = true;
                }
            });
            if (flag) {
                this.$message({
                    message: "最多上传一份协议",
                    type: "error"
                });
                return false;
            }
            let url =
                this.$baseUrl +
                "emergency/importEmergency?companyId=" +
                this.companyId;
            var fd = new FormData();
            fd.append("file", file.file);
            fd.append(
                "userName",
                JSON.parse(localStorage.getItem("user")).userAccount
            );
            let config = {
                headers: {
                    "Content-Type": "multipart/form-data"
                }
            };
            this.wordmsg = "上传中";
            this.loading = true;
            this.$axios.post(url, fd, config).then(res => {
                this.loading = false;
                console.log(res);
                if (res.data.meta.success) {
                    this.$message({
                        message: "上传成功",
                        type: "success"
                    });
                    this.lookdetailrecord();
                } else {
                    if (res.data.meta.message) {
                        this.$message({
                            message: res.data.meta.message,
                            type: "error"
                        });
                    } else {
                        this.$message({
                            message: "请下载相应的模板填写内容后，再上传文件",
                            type: "error"
                        });
                    }
                }
            });
        },
        judgeRequired () {
            this.$axios({
                method: "get",
                url: this.$baseUrl + "emergency/v2.0/check/save/" + JSON.parse(localStorage.getItem("user")).companyId + '/1'
            })
                .then(res => {
                    if (res.data.meta.success) {
                        this.saveriskList();
                    } else {
                        this.$message.warning(res.data.meta.message)
                    }
                })
                .catch(response => {
                    console.log(response);
                });
        },
        saveriskList () {
            let a = false;
            let b = false;
            let c = false;

            this.contentList.forEach(item => {
                if (item.uploadType == 1) {
                    a = true;
                } else if (item.uploadType == 2) {
                    b = true;
                } else if (item.uploadType == 3) {
                    c = true;
                }
            });
            if (!a) {
                this.$message({
                    message: "请上传内部应急组织机构",
                    type: "error"
                });
                return false;
            }
            if (!b) {
                this.$message({
                    message: "请上传外部应急救援队伍",
                    type: "error"
                });
                return false;
            }
            if (!c) {
                this.$message({
                    message: "请上传应急救援装备",
                    type: "error"
                });
                return false;
            }

            let hrr = JSON.parse(localStorage.getItem("newList"));

            // if(this.$route.query.riskIds){
            //  let brr =  this.$route.query.riskIds.split(",");
            if (hrr.length < 2) {
                //  window.localStorage.setItem("")
                this.$message({
                    message: "请选择至少所需的两条风险库",
                    type: "error"
                });
                return false;
            }
            let drrstring = [];
            hrr.forEach(item => {
                drrstring = [...drrstring, item.riskId];
            });
            let riskIds = drrstring.join(",");
            let params = {
                companyId: this.companyId,
                riskIds: riskIds
            };
            let a1 = 0;
            this.wordmsg = "文档生成中，请耐心等待...  已加载 0%";

            this.loading = true;
            setTimeout(() => {
                this.wordmsg = "文档生成中，请耐心等待...  已加载 10%";
            }, 3000);
            setTimeout(() => {
                this.wordmsg = "文档生成中，请耐心等待...  已加载 20%";
            }, 6000);
            setTimeout(() => {
                this.wordmsg = "文档生成中，请耐心等待...  已加载 30%";
            }, 15000);
            setTimeout(() => {
                this.wordmsg = "文档生成中，请耐心等待...  已加载 50%";
            }, 25000);
            setTimeout(() => {
                this.wordmsg = "文档生成中，请耐心等待...  已加载 70%";
            }, 45000);
            this.$axios({
                method: "post",
                url: this.$baseUrl + "emergency/v1.0/plan/create",
                data: params
            })
                .then(res => {
                    this.wordmsg = "文档生成中，请耐心等待...已加载100%";
                    this.loading = false;
                    if (res.data.meta.success) {
                        this.$message({
                            message: "保存成功",
                            type: "success"
                        });
                        // this.lookdetailrecord();
                        this.$router.push({
                            path: "/estimate",
                            query: {
                                navChildren: this.$route.query.navChildren,
                                navIndex: this.$route.query.navIndex
                            }
                        });
                    } else {
                        this.$message({
                            message: res.data.meta.message,
                            type: "error"
                        });
                    }
                })
                .catch(function (error) {
                    this.loading = false;
                });
        },
        deleteMsg () {
            let params = {
                companyId: "string",
                riskIds: "string"
            };
            this.$axios({
                method: "post",
                url: this.$baseUrl + "emergency/v1.0/plan/create",
                data: params
            }).then(res => {
                console.log(this.levelfirst);
            });
        },
        exportInto () {
            let params = {
                companyId: "string",
                riskIds: "string"
            };
            this.$axios({
                method: "post",
                url: this.$baseUrl + "emergencyresources/v1.0/importExecl",
                data: params
            }).then(res => {
                console.log(this.levelfirst);
            });
        },
        looknew1 () {
            //查看内部机构联系人
            let params = {
                companyId: this.companyId,
                current: this.pageIndex,
                size: this.pageSize
            };
            this.$axios({
                method: "post",
                url:
                    this.$baseUrl +
                    "emergencyresources/v1.0/equipment/queryInnerInfo",
                params: params
            }).then(res => {
                if (res.data.meta.success) {
                    this.firstVisibleList = res.data.data.records;
                    this.total = res.data.data.total;
                    this.firstVisible = true;
                }
            });
        },
        looknew2 () {
            //查看外部应急救援联系方式
            let params = {
                companyId: this.companyId,
                current: this.pageIndex1,
                size: this.pageSize1
            };
            this.$axios({
                method: "post",
                url:
                    this.$baseUrl +
                    "emergency/queryemergency?companyId=" +
                    this.companyId +
                    "&current=" +
                    this.pageIndex1 +
                    "&size=" +
                    this.pageSize1,
                data: {}
            }).then(res => {
                if (res.data.meta.success) {
                    this.twoVisibleList = res.data.data.records;
                    this.total2 = res.data.data.total;
                    this.twoVisible = true;
                }
            });
        },
        looknew3 () {
            //查看应急装备清单
            let params = {
                companyId: this.companyId,
                current: this.pageIndex2,
                size: this.pageSize2
            };
            this.$axios({
                method: "post",
                url:
                    this.$baseUrl +
                    "emergencyresources/v1.0/equipment/queryInfo",
                params: params
            }).then(res => {
                this.threeVisibleList = res.data.data.records;
                this.total1 = res.data.data.total;
                this.threeVisible = true;

                //  this.lookdetailrecord();
            });
        },
        looknew4 (item) {
            //预览救援协议
            this.$axios({
                method: "post",
                url:
                    this.$baseUrl +
                    "emergency/queryAgreement?companyId=" +
                    this.companyId +
                    "&id=" +
                    item.id,
                data: {}
            })
                .then(res => {
                    // this.looknew4(
                    // this.fourVisible = true;
                    if (res.data.meta.success) {
                        this.mgsUrl = res.data.data;
                        //  this.lookstatus(this.mgsUrl);
                        //  window.open(this.mgsUrl, "_blank");
                        //  debugger;
                        var tempwindow = window.open("_blank"); //打开一个窗口，然后用

                        tempwindow.location = this.mgsUrl; //使这个窗口跳转到百度，这样就会呈现弹出百度窗口的效果了。
                    }
                    //  this.lookdetailrecord();
                    // this.message =
                })
                .catch(err => {
                    console.log(err);
                });
        },
        deletenew1 () {
            //删除内部机构联系人
            let params = {
                单位id: this.companyId
            };
            this.$axios({
                method: "post",
                url:
                    this.$baseUrl +
                    "emergencyresources/v1.0/equipment/deleteemergencyOrg?companyId=" +
                    this.companyId,
                data: {}
            }).then(res => {
                if (res.data.meta.success) {
                    this.$message({
                        message: "删除成功",
                        type: "success"
                    });
                } else {
                    this.$message({
                        message: res.data.meta.message,
                        type: "error"
                    });
                }
                this.lookdetailrecord();
            });
        },
        deletenew2 () {
            //删除外部应急救援联系方式
            let params = {
                companyId: this.companyId
            };
            this.$axios({
                method: "post",
                url:
                    this.$baseUrl +
                    "emergency/deleteemergency?companyId=" +
                    this.companyId,
                data: params
            }).then(res => {
                if (res.data.meta.success) {
                    this.$message({
                        message: "删除成功",
                        type: "success"
                    });
                } else {
                    this.$message({
                        message: res.data.meta.message,
                        type: "error"
                    });
                }
                this.lookdetailrecord();
                console.log(this.levelfirst);
            });
        },
        deletenew3 () {
            //删除应急装备清单
            let params = {
                companyId: this.companyId
            };
            this.$axios({
                method: "post",
                url:
                    this.$baseUrl +
                    "emergencyresources/v1.0/equipment/deleteequipment?companyId=" +
                    this.companyId,
                data: {}
            }).then(res => {
                if (res.data.meta.success) {
                    this.$message({
                        message: "删除成功",
                        type: "success"
                    });
                } else {
                    this.$message({
                        message: res.data.meta.message,
                        type: "error"
                    });
                }
                this.lookdetailrecord();
                console.log(this.levelfirst);
            });
        },
        deletenew4 (item) {
            //删除协议
            let params = {
                companyId: this.companyId,
                id: item.id,
                uploadType: "4"
            };
            this.$axios({
                method: "post",
                url: this.$baseUrl + "emergency/deleteAgreement",
                data: params
            }).then(res => {
                if (res.data.meta.success) {
                    this.$message({
                        message: "删除成功",
                        type: "success"
                    });
                } else {
                    this.$message({
                        message: res.data.meta.message,
                        type: "error"
                    });
                }
                this.lookdetailrecord();
                console.log(this.levelfirst);
            });
        },
        deletedetail (item) {
            if (item.uploadType == 1) {
                this.deletenew1();
            } else if (item.uploadType == 2) {
                this.deletenew2();
            } else if (item.uploadType == 3) {
                this.deletenew3();
            } else if (item.uploadType == 4) {
                this.deletenew4(item);
            }
        },
        lookdetail (item) {
            if (item.uploadType == 1) {
                this.looknew1();
            } else if (item.uploadType == 2) {
                this.looknew2();
            } else if (item.uploadType == 3) {
                this.looknew3();
            } else if (item.uploadType == 4) {
                this.looknew4(item);
            }
        },
        lookdetailrecord () {
            this.$axios({
                method: "get",
                url:
                    this.$baseUrl +
                    "emergencyresources/v1.0/equipment/queryuploadfilerecords/" + this.companyId
            }).then(res => {
                if (res.data.data) {
                    this.contentList = res.data.data;
                } else {
                    this.contentList = [];
                }
            });
        },
        lookstatus (item) {
            let baseUrl = item;
            var urlpath = baseUrl.indexOf("?") + 1;
            urlpath = baseUrl.substring(urlpath);
            var arrapi = urlpath.split("&");
            let uesrMessage = {};
            arrapi.forEach(item => {
                var brrapi = [];
                brrapi = item.split("=");
                uesrMessage[brrapi[0]] = brrapi[1];
            });

            let id = uesrMessage.srcFid;
            let expires = Date.parse(new Date());
            let a = "FastDFS1234Bossien" + id + expires;
            console.log(a);
            let token = this.$md5(a);
            token = token.toUpperCase();

            this.$axios({
                method: "get",
                // url:"/queryPublishFileInfo.do?appId=001&scrFid="+id+"&expires="+expires+"&token="+token,
                url:
                    "/queryPublishFileInfo.do?appId=002&srcFid=" +
                    id +
                    "&expires=" +
                    expires +
                    "&token=" +
                    token,
                data: {}
            }).then(res => {
                // debugger;
                let status = JSON.parse(res.data);
                if (status.dataObj.srcFileStatusDesc == "PDF文件上传完成") {
                    var tempwindow = window.open("_blank"); //打开一个窗口，然后用

                    tempwindow.location = item; //使这个窗
                } else {
                    this.$message({
                        message: "文件正在转码中，请稍后有查看",
                        type: "error"
                    });
                }
            });
        },
        changeimg3 () { },
        savecreate () {
            let params = {
                companyId: this.companyId,
                riskIds: this.$route.query.riskIds
            };
            setTimeout(() => {
                //  this.loading = true;
            }, 1000);
            this.$axios({
                method: "post",
                url: this.$baseUrl + "emergency/v1.0/plan/create",
                data: params
            }).then(res => {
                this.loading = false;
                let data = res.data.meta;
                if (data.success) {
                    this.$router.push({ path: 'resources', query: { navIndex: 1 } });
                } else {
                    this.$message({
                        message: res.data.meta.message,
                        type: "error"
                    });
                }
            });
        }
    },
    filters: {
        innerOrg: function (value) {
            if (value == 6 || value == 7) {
                return "../../../static/内部应急组织机构（发电）.xlsx";
            } else {
                return "../../../static/内部应急组织机构.xlsx";
            }
        },
        changestatus (val) {
            if (!val) {
                return "";
            }
            // 1.组长 2副组长 5成员 3主任 4副主任
            if (val == 1) {
                return "组长";
            } else if (val == 2) {
                return "副组长";
            } else if (val == 3) {
                return "主任";
            } else if (val == 4) {
                return "副主任";
            } else if (val == 5) {
                return "成员";
            }
        },
        changeType (val) {
            if (!val) {
                return "";
            }
            if (val == 1) {
                return "突发事件应急领导小组";
            } else if (val == 2) {
                return "突发事件应急办公室";
            } else if (val == 3) {
                return "抢险技术组";
            } else if (val == 4) {
                return "医疗及后勤保障组";
            } else if (val == 5) {
                return "警戒疏散组";
            } else if (val == 6) {
                return "网络信息安全组";
            } else if (val == 7) {
                return "善后处理组";
            }
        },
        changelink (val) {
            if (!val) {
                return "";
            }
            if (val == 1) {
                return "上级单位";
            } else if (val == 2) {
                return "市消防大队";
            } else if (val == 3) {
                return "区公安局";
            } else if (val == 4) {
                return "市消防大队";
            } else if (val == 5) {
                return "市环保局";
            } else if (val == 6) {
                return "警察局";
            } else if (val == 7) {
                return "消防大队";
            }
        },
        sizechange (val) {
            if (!val) {
                return "";
            }
            var num = 1024;
            if (val < 1024) {
                return val + "k";
            } else {
                return (val / num).toFixed(2) + "M";
            }
        },
        timechange (val) {
            if (!val) {
                return "";
            }
            return val.substring(0, 19);
        },

        timeselect (val) {
            if (!val) {
                return false;
            }
            let DateS = new Date();
            let newDate = new Date(val);

            let num = (DateS - newDate) / 1000 / 60;
            if (num > 1) {
                return false;
            } else {
                return true;
            }
        }
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang='less'>
@import "../../../static/css/information.less";
.resources {
    .resource {
        .el-button {
            border-radius: 8px;
            height: 36px;
        }
        .form-container {
            padding: 50px 0 70px;
            margin: 0 auto;
            .el-table {
                width: calc(100% - 200px);
                margin: 0 auto;
                border-top: 1px solid #ebeef5;
            }
            .bts-group {
                padding-left: 100px;
                margin-bottom: 20px;
                height: 36px;
                .grp1 {
                    background: #fff;
                    color: #3f80fe;
                    border: 1px solid #3f80fe;
                }
                .grp2 {
                    background: #f6f6fe;
                    border: 1px solid #f6f6fe;
                    color: #3f80fe;
                }
                .grp2:hover {
                    background: #fff;
                    color: #3f80fe;
                    border: 1px solid #3f80fe;
                }
                .el-button.sure {
                    color: #fff;
                    width: 120px;
                    height: 36px;
                    background: #4080ff;
                    /*background: linear-gradient(
                        90deg,
                        #6eb1ff 20%,
                        #3372ff 80%
                    );*/
                }
                .el-button.sure:hover {
                    opacity: 0.8;
                }
            }
        }

        .detail-btn {
            border: 0;
            color: #4180ff;
            background: #f7f6fe;
            border: 1px solid #4180ff;
            border-radius: 8px;
        }
    }
    .resource-title {
        font-size: 20px;
        color: #656565;
        font-weight: bold;
        text-align: center;
        margin: 14px 0 30px 0;
    }
    .resource-bts {
        width: 200px;
        margin: 0 auto;
        .el-button {
            width: 200px;
            height: 42px;
            color: #4080fe;
            border: 1px solid #4080fe;
            margin-bottom: 20px;
            margin-left: 0;
        }
        > a {
            width: 200px;
            height: 42px;
            color: #4080fe;
            border: 1px solid #4080fe;
            margin-bottom: 20px;
            margin-left: 0;
            display: block;
            line-height: 42px;
            text-align: center;
            color: #000;
            border-radius: 4px;
        }
        > a:hover {
            background-color: #ecf5ff;
        }
        .btn-active {
            padding: 0;
        }
        > a.btn-active {
            background: #4080fe;
            color: #fff;
        }
    }
}
.items {
    float: left;
    margin-right: 16px;
}
</style>
